<?php

/**
 * This is the model class for table "customer".
 *
 * The followings are the available columns in table 'customer':
 * @property integer $id
 * @property string $firstName
 * @property string $lastName
 * @property string $email
 * @property string $password
 * @property string $street1
 * @property string $street2
 * @property string $city
 * @property string $state
 * @property string $zipCode
 * @property string $country
 * @property string $createTime
 * @property string $lastLoginTime
 *
 * The followings are the available model relations:
 * @property Customerquote[] $customerquotes
 */
class Customer extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @param string $className active record class name.
	 * @return Customer the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'customer';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('firstName, lastName, email, password, street1, city, state, zipCode, createTime', 'required'),
			array('firstName, lastName, email, city, state, country', 'length', 'max'=>50),
			array(' zipCode', 'length', 'max'=>10),
			array('password', 'length', 'max'=>255),
			array('street1, street2', 'length', 'max'=>100),
			array('lastLoginTime', 'safe'),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('id, firstName, lastName, email, password, street1, street2, city, state, zipCode, country, createTime, lastLoginTime', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
			'customerquotes' => array(self::HAS_MANY, 'Customerquote', 'customerId'),
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'id' => 'ID',
			'firstName' => 'First Name',
			'lastName' => 'Last Name',
			'email' => 'Email',
			'password' => 'Password',
			'street1' => 'Street1',
			'street2' => 'Street2',
			'city' => 'City',
			'state' => 'State',
			'zipCode' => 'Zip Code',
			'country' => 'Country',
			'createTime' => 'Create Time',
			'lastLoginTime' => 'Last Login Time',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('id',$this->id);
		$criteria->compare('firstName',$this->firstName,true);
		$criteria->compare('lastName',$this->lastName,true);
		$criteria->compare('email',$this->email,true);
		$criteria->compare('password',$this->password,true);
		$criteria->compare('street1',$this->street1,true);
		$criteria->compare('street2',$this->street2,true);
		$criteria->compare('city',$this->city,true);
		$criteria->compare('state',$this->state,true);
		$criteria->compare('zipCode',$this->zipCode,true);
		$criteria->compare('country',$this->country,true);
		$criteria->compare('createTime',$this->createTime,true);
		$criteria->compare('lastLoginTime',$this->lastLoginTime,true);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}
}